<?php

/**
 * Classe responsável por gerenciar a criação de mensagens do sistema
 * @name SystemMessage
 * @author Fabio Baía baiacfabio@gmail.com
 * @since 24/04/2013 03:05:00
 */
class SystemMessage {
	
	const TYPE_INFO = 1;
	const TYPE_NOTICE = 2;
	const TYPE_ERROR = 3;
	const TYPE_SUCCESS = 4;
	
	private $message;
	private $typeMessage;
	private $stackTrace;
	
	
	/**
	* @access public
	* @name createMessage
	* @param string $message Mensagem
	* @param int $type_message Tipo da mensagem
	* @since 24/04/2013 03:11:40
	*/
	public static function createMessage($message, $type_message, $stackTrace = null) {
		
		$_SESSION["system_info"] = '
		<script type="text/javascript">
		$(document).ready(function() {
			setTimeout(function() {
			    // Do something after 5 seconds
				$("div.system_message").slideUp("slow");
			}, 5000);
				
			$("div.system_message span").click(function(){
				$("div.system_message").slideUp("slow");
			});
		});
		</script>
		';
		
		switch ($type_message) {
			case 1:{
				$_SESSION["system_info"] .= '<div class="system_message info">'.$message.'<span style="
    background: url(images/close.png) no-repeat right; width: 12px; height: 12px;
    float: right;
    cursor: pointer;
"></span></div>';
				break;
			};
			case 2:{
				$_SESSION["system_info"] .= '<div class="system_message notice">'.$message.'<span style="
    background: url(images/close.png) no-repeat right; width: 12px; height: 12px;
    float: right;
    cursor: pointer;
"></span></div>';
				break;
			};
			case 3:{
				$_SESSION["system_info"] .= '<div class="system_message error">'.$message.'<span style="
    background: url(images/close.png) no-repeat right; width: 12px; height: 12px;
    float: right;
    cursor: pointer;
"></span></div>';
				break;
			};
			case 4:{
				$_SESSION["system_info"] .= '<div class="system_message success">'.$message.'<span style="
    background: url(images/close.png) no-repeat right; width: 12px; height: 12px;
    float: right;
    cursor: pointer;
"></span></div>';
				break;
			};			
		}	
	}
}